package uk.co.wroedevelopments.semanticworkbench.query;

import org.eclipse.emf.ecore.EObject;
import org.xtext.example.semQryDsl.Node;
import org.xtext.example.semQryDsl.Pattern;
import org.xtext.example.semQryDsl.RelationshipType;
import org.xtext.example.semQryDsl.SemQryDslPackage;

public class QueryUtils {
	
	public final static String NODE_ID_FIELD = "name";
	
	private static SemQryDslPackage MODEL_PACKAGE = SemQryDslPackage.eINSTANCE;
	
	
	public static boolean hasConcreteInstance(Pattern p) {
		return (isInstance(p.getSubject()) || isInstance(p.getObject()));

	}
	
	public static boolean hasBothConcreteInstance(Pattern p) {
		return (isInstance(p.getSubject()) && isInstance(p.getObject()));

	}

	public static boolean isInstance(Node nde) {
		return (nde.eClass().eContainer() == MODEL_PACKAGE && nde.eClass()
				.getClassifierID() == SemQryDslPackage.INSTANCE_ID);
	}

	public static boolean isQuery(EObject obj) {
		return (obj.eClass().eContainer() == MODEL_PACKAGE && obj.eClass()
				.getClassifierID() == SemQryDslPackage.QUERY);
	}

	public static boolean hasConcretePredicate(Pattern pattern) {
		// TODO Auto-generated method stub
		return false;
	}

	public static boolean isRelationshipInstance(RelationshipType predicate) {
		return (predicate.eClass().eContainer() == MODEL_PACKAGE && predicate.eClass()
				.getClassifierID() == SemQryDslPackage.RELATIONSHIP_TYPE);
	}
}
